package com.example.demo.service

import com.example.demo.JsonUtil
import com.example.demo.SQLUtil
import com.example.demo.bean.BaseResponse
import com.example.demo.bean.Room
import com.example.demo.bean.SUCCESS
import javax.servlet.annotation.WebServlet
import javax.servlet.http.HttpServlet
import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse

@WebServlet(name = "all_room", value = ["/all_room"])
class AllRoomServlet : HttpServlet() {
    override fun doGet(req: HttpServletRequest, resp: HttpServletResponse) {
        resp.contentType = "text/json;charset=UTF-8"
        resp.writer.println(
            JsonUtil.toJson(
                BaseResponse<List<Room>>(
                    code = SUCCESS,
                    data = SQLUtil.getWholeRoomInfo()
                )
            )
        )
    }
}